<?php
namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Services\IndexService;
use Illuminate\Http\Request;

class IndexController extends Controller
{
    private static $indexService;

    /**
     * 依赖注入
     * @param IndexService $indexService
     */
    public function __construct(IndexService $indexService)
    {
        self::$indexService = $indexService;
    }

    /**
     *
     * User: zhouyao
     * Date: 2018/8/26
     * Time: 下午4:28
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\AppException
     */
    public function bannerList(Request $request)
    {
        $input = $request->all();
        $param = json_decode($input['param'], true);
        $result = self::$indexService->bannerList($param);
        return app_response(200, $result);
    }

    /**
     * 获取商品分类
     * User: zhouyao
     * Date: 2018/8/26
     * Time: 下午5:28
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\AppException
     */
    public function category(Request $request)
    {
        $input = $request->all();
        $param = json_decode($input['param'], true);
        $result = self::$indexService->category($param);
        return app_response(200, $result);
    }
}